package com.lumberer.pay2021.common;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.lumberer.pay2021.util.Result;
/**
 * 统一异常处理
 * 这里可以对自定义异常进行特殊处理
 * @author lumberer
 * 
 */
@RestControllerAdvice
@ControllerAdvice
public class GlobalExceptionHandler {
	/**
	 * 通用异常处理类
	 * @param req
	 * @param e
	 * @return
	 */
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result jsonErrorHandler(HttpServletRequest req, Exception e){
        return Result.error(500, e.getMessage(),null);
    }
}
